package com.member.model;

import java.text.DateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.json.JSONArray;

import com.member.model.MemberVO;

public class MemberJsonHandler {

	
	public MemberJsonHandler() {
		super();
	}

	public JSONArray toJSONArray(List<MemberVO> memberList) {
		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
		for (MemberVO member : memberList) {
			HashMap<String, String> map = new HashMap<String, String>();
			
			
			String member_id = member.getMember_id();			
			String name = member.getName();
			String nickname = member.getNickname();
			String sex = member.getSex();
			String national_id = member.getNational_id();
			DateFormat df = DateFormat.getDateInstance();
			String birthday = df.format(member.getBirthday());
			String address = member.getAddress();
			String phone = member.getPhone();
			
			map.put("member_id", member_id);
			map.put("name", name);
			map.put("nickname", nickname);
			map.put("sex", sex);
			map.put("national_id", national_id);
			map.put("birthday", birthday);
			map.put("address", address);
			map.put("phone", phone);
			list.add(map);		
			
		}
		JSONArray memberJson = new JSONArray(list);
		return memberJson;
	}

	
	
	
	
	
	
	
	
}
